package com.yixun.qfbao.interceptor.forbidrepeatclick.response;
/**
 * @author zilong.liu
 * @date 2020-11-23
 *
 * desc:
 *     
 */

import org.springframework.beans.BeansException;
import org.springframework.context.ApplicationContext;
import org.springframework.context.ApplicationContextAware;
import org.springframework.stereotype.Component;

@Component
public class ResponseFactory implements ApplicationContextAware{
	
	private static ApplicationContext applicationContext;
	
	/**
	 * 获取对应类型的返回值
	 * @return
	 */
	public static ResTypeResponse getResTypeResponse(String resType) {
		String beanName = ResponseTypeEnum.getBeanNameByResType(resType);
		return (ResTypeResponse)applicationContext.getBean(beanName);
	}

	@Override
	public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
		ResponseFactory.applicationContext = applicationContext;
	}
}
